/* indent:4  tabsize:8  font:fixed-width */

#import "KlondikePrefs.h"

@implementation KlondikePrefs


/*---------------------------------------------------------------------------
|
|    - registerPrefs
|
|    returns: (id) self
|
|----------------------------------------------------------------------------
|
|    Register the preferences for this game.  Called automatically.
|			
\---------------------------------------------------------------------------*/

- registerPrefs
{
    const NXDefaultsVector gameDefaults =
    {
        {"CardsToDraw", "3"},
        {NULL, NULL}
    };

    NXRegisterDefaults(gameName, gameDefaults);

    cardsToDraw = atoi(NXGetDefaultValue(gameName, "CardsToDraw"));
    [cardsToDrawMatrix selectCellWithTag:cardsToDraw];

    return self;
}

/*---------------------------------------------------------------------------
|
|    - saveCardsToDraw:sender
|
|    returns: (id) self
|
|----------------------------------------------------------------------------
|
|    Save "CardsToDraw" preference.
|			
\---------------------------------------------------------------------------*/

- saveCardsToDraw:sender
{
    char buffer[80];

    cardsToDraw = [cardsToDrawMatrix selectedTag];
    sprintf(buffer, "%d", cardsToDraw);
    NXWriteDefault(gameName, "CardsToDraw", buffer);
    return self;
}

/*---------------------------------------------------------------------------
|
|    - cardsToDraw:sender
|
|    returns: (int) number of cards to draw from stock
|
|----------------------------------------------------------------------------
|
|    Return "CardsToDraw" preference.
|			
\---------------------------------------------------------------------------*/

- (int)cardsToDraw
{
    return cardsToDraw;
}



@end
